package com.dyna.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dyna.foundation.domain.entity.SysRoleMenu;
import org.apache.ibatis.annotations.Mapper;

import java.util.Collection;
import java.util.List;

/**
* @author zhoucaiwang
*/

@Mapper
public interface SysRoleMenuMapper extends BaseMapperX<SysRoleMenu> {

    default List<SysRoleMenu> selectListByRoleId(Long roleId) {
        return selectList(SysRoleMenu::getRoleId, roleId);
    }

    default List<SysRoleMenu> selectListByRoleId(Collection<Long> roleIds) {
        return selectList(SysRoleMenu::getRoleId, roleIds);
    }

    default void deleteListByRoleIdAndMenuIds(Long roleId, Collection<Long> menuIds) {
        delete(new LambdaQueryWrapper<SysRoleMenu>()
                .eq(SysRoleMenu::getRoleId, roleId)
                .in(SysRoleMenu::getMenuId, menuIds));
    }

    default void deleteListByRoleId(Long roleId) {
        delete(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getRoleId, roleId));
    }

    default void deleteListByMenuId(Long menuId) {
        delete(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getMenuId, menuId));
    }

}




